<%@ page contentType="text/html; charset=UTF-8" import="java.sql.Statement"%>
<%@ page import="java.io.*" %>
<%@ page import="java.util.*" %>

<jsp:useBean id="tranData" scope="request" class="dqcs.BatchDownloadDqcsAttach">
</jsp:useBean>
<%
    String[] lstrParam=new String[2];
    Statement stmtExecute=null;


  try{
    if (request.getContentType() != null && request.getContentType().indexOf("multipart") < 0) {
      if(request.getParameter("action")!=null && request.getParameter("action").equals("single")){
        stmtExecute=tranData.getConn("rmadb","dqcs").createStatement();

        if(request.getParameter("pn")!=null && !request.getParameter("pn").equals("") && (request.getParameter("model")==null || request.getParameter("model").equals(""))){
          stmtExecute.executeUpdate("update dqcs_down_pn set expand='N' where pn='" + request.getParameter("pn") + "'");
        }
        else if(request.getParameter("model")!=null && !request.getParameter("model").equals("") && (request.getParameter("pn")==null || request.getParameter("pn").equals(""))){
          stmtExecute.executeUpdate("update dqcs_down_pn set expand='N' where model='" + request.getParameter("model") + "'");
        }
        else{
          if(stmtExecute.executeUpdate("update dqcs_down_pn set expand='N' where model='" + request.getParameter("model") + "' and pn='" + request.getParameter("pn") + "'")==0){
            stmtExecute.executeUpdate("insert into dqcs_down_pn values('" + request.getParameter("pn") + "','" + request.getParameter("model") + "','" + request.getParameter("empno") + "',sysdate,'N')");
          }
        }

        lstrParam[0]="rmadb";
        lstrParam[1]="9999";
        tranData.main(lstrParam);

        lstrParam[0]="dqcs2";
        tranData.main(lstrParam);
      }
    }
  }
  catch(Exception e){
    e.printStackTrace();
  }
  finally{
    try{
      if(stmtExecute!=null){
        stmtExecute.close();
        stmtExecute=null;
      }
    }catch(Exception se){
      se.printStackTrace();
    }
  }
%>
<html>
<head>
<title>
InputPN
</title>
</head>
<body bgcolor="#ffffff">
<form method="post" action="InputPN.jsp">
PN:<input type="text" size="25" maxlength="25" name="pn" /><br />
Model:<input type="text" size="20" maxlength="20" name="model" /><br />
工號:<input type="text" size="8" maxlength="25" name="empno" /><br />
<input type="submit" name="Submit" value="Submit">
<input type="reset" value="Reset">
<input type="hidden" name="action" value="single"/>
</form>
</body>
</html>
